home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DIRS.SWG / 0010_DIRVIEW.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  87 lines

  1. {
  2. Well, here goes...a directory viewer, sorry it has no box but the
  3. command that i used to create the box was from a Unit. Weel, the Program
  4. is very "raw" but i think it's enough to give you an idea...
  5. }
  6.  
  7. Program ListBox;
  8.  
  9. Uses
  10.   Crt, Dos;
  11.  
  12. Const
  13.   S = '           ';
  14.  
  15. Var
  16.   List         : Array[1..150] of String[12];
  17.   AttrList     : Array[1..150] of String[15];
  18.   Pos, First   : Integer;
  19.   C            : Char;
  20.   Cont         : Integer;
  21.   DirInfo      : SearchRec;
  22.   NumFiles     : Integer;
  23.  
  24. begin
  25.   TextBackground(Black);
  26.   TextColor(LightGray);
  27.   ClrScr;
  28.  
  29.   For Cont := 1 to 15 do
  30.   begin
  31.     List[Cont] := '';
  32.     AttrList[Cont] := '';
  33.   end;
  34.  
  35.   NumFiles := 0;
  36.   FindFirst('C:\*.*', AnyFile, DirInfo);
  37.  
  38.   While DosError = 0 do
  39.   begin
  40.     Inc(NumFiles, 1);
  41.     List[NumFiles] := Concat(DirInfo.Name,
  42.                       Copy(S, 1, 12 - Length(DirInfo.Name)));
  43.     If (DirInfo.Attr = $10) Then
  44.       AttrList[NumFiles] := '<DIR>'
  45.     Else
  46.       Str(DirInfo.Size, AttrList[NumFiles]);
  47.     AttrList[NumFiles] := Concat(AttrList[NumFiles],
  48.                           Copy(S, 1, 9 - Length(AttrList[NumFiles])));
  49.     FindNext(DirInfo);
  50.   end;
  51.  
  52.   First := 1;
  53.   Pos   := 1;
  54.  
  55.   Repeat
  56.     For Cont := First To First + 15 do
  57.     begin
  58.       If (Cont - First + 1 = Pos) Then
  59.       begin
  60.         TextBackground(Blue);
  61.         TextColor(Yellow);
  62.       end
  63.       Else
  64.       begin
  65.         TextBackGround(Black);
  66.         TextColor(LightGray);
  67.       end;
  68.       GotoXY(30, Cont - First + 3);
  69.       Write(' ', List[Cont], '  ', AttrList[Cont]);
  70.     end;
  71.     C := ReadKey;
  72.     If (C = #72) Then
  73.       If (Pos > 1) Then
  74.         Dec(Pos, 1)
  75.       Else
  76.       If (First > 1) Then
  77.         Dec(First,1);
  78.  
  79.     If (C = #80) Then
  80.       If (Pos < 15) Then
  81.         Inc(Pos, 1)
  82.       Else
  83.       If (First + 15 < NumFiles) Then
  84.         Inc(First,1);
  85.   Until (Ord(c) = 13);
  86. end.
  87.